import { ApiCall } from "tsrpc";
import { player } from "../../../model/fight/body/player";
import { ReqLook, ResLook } from "../../../shared/master/bag/PtlLook";
import { template } from "../../../shared/master/MsgAction";
import { prop_equip } from "../../../model/bag/prop_equip";
import manage_EquipStrengthen from "../../model/manage/manage_EquipStrengthen";

export default async function (call: ApiCall<ReqLook, ResLook>) {
    let user = call.req._player as player;
    let lookIdx = call.req.idx;
    let resArry = user.getBagList();
    let lookItem = resArry[lookIdx];
    if (!lookItem) {
        user.sendMsg(template.default, `背包内没有找到ID${lookIdx + 1}的道具`)
        call.succ({})
        return;
    }
    if (lookItem instanceof prop_equip) {
        manage_EquipStrengthen.update(user.uuid, lookItem.data)
    }
    let Msg = lookItem.look(user);
    user.sendMsg(Msg.template, Msg.data)
    call.succ({})
}